package testtiles;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

import butines.core.game.Image;


public class ImageDebug {

	public static void main(String[] args) throws Exception {
		Image img = new Image("datas/summer.png");
		
		int tilep = 10; // padding
		int tilew = 32;
		int tileh = 32;

		int numX = 16;
		int numY = 24;
		
		int w = (numX * (tilew + tilep * 2));
		int h = (numY * (tileh + tilep * 2));
		
		BufferedImage buff = new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR);
		
		for (int y = 0; y < numY; y++) {
			for (int x = 0; x < numX; x++) {
				int offsetx = x * (tilew + tilep * 2);
				int offsety = y * (tileh + tilep * 2);
				int dx1 = offsetx + tilep;
				int dy1 = offsety + tilep;
				int dx2 = dx1 + tilew;
				int dy2 = dy1 + tileh;
				int sx1 = x * tilew;
				int sy1 = y * tileh;
				int sx2 = sx1 + tilew;
				int sy2 = sy1 + tileh;
				
				Graphics g = buff.getGraphics();
				g.setColor(Color.red);
				g.drawRect(dx1-1, dy1-1, dx2-dx1+1, dy2-dy1+1);
				g.drawImage(img.getRaw(),
					dx1, dy1, dx2, dy2,
					sx1, sy1, sx2, sy2, null);
				int tx = dx1;
				int ty = dy1 + tilep - (g.getFontMetrics().getHeight()) + 4;
				g.drawString(String.valueOf(x + (numX * y)), tx, ty);
			}
		}
		
		File file = new File("C:/marvin/dev/java_3/workspace/project-butines/teste.png");
		ImageIO.write(buff, "PNG", file);
		
	}
	
}
